﻿$(document).ready(function () {
     $('#txt-comment-submit').click(function () {
         var id_sp = $('#comment-view').data('id');
         var txtCmt = $('#txt-comment-input').val();
         if (txtCmt != '') {
             $.get('/Ajax/Gui_Binh_Luan', { txt: txtCmt, ID_SP: id_sp }, function (html) {
                 $('#comment-view').html(html);
             });
         } else return false;
     });
 
     $('.delete-comment').click(function () {
         var id_sp = $('#comment-view').data('id');
         var id_cmt = $(this).data('id');
         $.get('/Ajax/Xoa_Binh_Luan', { ID_Cmt: id_cmt, ID_SP: id_sp }, function (html) {
             $('#comment-view').html(html);
         });
     });

    $('#show-hide-box-comment').click(function () {
        if ($(this).parent('.user-comment-input').css('top') != '0px') {
            $(this).parent('.user-comment-input').stop(true, true).animate({ 'top': '0' });
            $(this).text('- Ẩn -');
        }
        else {
            $(this).parent('.user-comment-input').stop(true, true).animate({ 'top': '-248px' });
            $(this).text('+ Thêm bình luận +');
        }
    });
});